﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Oracle;

namespace card
{
    public partial class Frm_PWDchange : Form
    {
        public static WebDG.Service ws = new card.WebDG.Service();
        public Frm_PWDchange()
        {
            InitializeComponent();
        }

        public static OracleDatabase db =
           new OracleDatabase("Data Source=sjzx;User ID=dbcenter;Password=ok;Unicode=True;Load Balance Timeout=1000");

        private void btn_ok_Click(object sender, EventArgs e)
        {
            if (txt_pwdnew.Text .Length  > 6)
            {
                MessageBox.Show("新密码输入长度超长，请重新输入（6个字符以内）。");
                txt_pwdnew.Focus();
                return;
            }
            if (txt_pwdnew.Text == txt_pwdagain.Text)
            {
                //MessageBox.Show("ok");
                
                string StrSql = "update user_info set KLKL='" + txt_pwdnew.Text + "' where YHBH='" +this.Text + "'";
                //MessageBox.Show(StrSql);
                int ret = ws.execute_UID_Serv(StrSql);
                //int ret = db.ExecuteNonQuery(db.GetSqlStringCommand(StrSql.ToString()));
                if (ret == 1)
                {
                    MessageBox.Show("密码修改成功。");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("密码修改失败。");
                }
            }
            else
            {
                MessageBox.Show("两次密码输入不一致，请重新输入。");
                txt_pwdnew.Focus ();
            }
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Frm_PWDchange_Load(object sender, EventArgs e)
        {

        }
    }
}
